package org.sage.sdk.dada.order.entity;

import lombok.Data;
import org.sage.sdk.dada.infrastructure.common.BaseEntity;
import org.sage.sdk.dada.infrastructure.common.attributes.CancelReason;
import org.sage.sdk.dada.infrastructure.common.attributes.CancelReasonId;
import org.sage.sdk.dada.infrastructure.common.attributes.OrderId;
import org.sage.sdk.dada.infrastructure.utils.GetBodyUtil;

import javax.validation.constraints.NotNull;

/**
 * 取消订单(线上环境)
 * <p>
 * 在订单待接单或待取货情况下，调用此接口可取消订单。注意：接单后1－15分钟内取消订单，运费退回。同时扣除2元作为给配送员的违约金
 * <p>
 * 接口调用请求说明，URL地址：/api/order/formalCancel
 *
 * @author 周广明
 * @version v1 2019/12/10 下午6:43
 */
@Data
public class CancelOrder implements BaseEntity {

    @Override
    public String getUrl() {
        return "/api/order/formalCancel";
    }

    @Override
    public String getBody() {
        return GetBodyUtil.toJsonStr(this);
    }

    public CancelOrder(OrderId orderId, CancelReasonId cancelReasonId, CancelReason cancelReason) {
        this.orderId = orderId;
        this.cancelReasonId = cancelReasonId;
        this.cancelReason = cancelReason;
    }

    @NotNull
    OrderId orderId;

    @NotNull
    CancelReasonId cancelReasonId;

    CancelReason cancelReason;
}
